﻿using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.Domain.Entity;
using Ghasam.Business.DAO;
using Spring.Transaction.Interceptor;

namespace Ghasam.Business.Services.Impl {
    public class SalesPersonService : ISalesPersonService {

        #region "Private Method"

        private ISalesPersonDao iSalesPersonDao;

        #endregion

        # region "Public Method"

        public ISalesPersonDao ISalesPersonDao {
            set { iSalesPersonDao = value; }
            get { return iSalesPersonDao; }
        }

        [Transaction(ReadOnly = false)]
        public SalesPerson SaveOrUpadate(SalesPerson salesPerson) {
            ISalesPersonDao.SaveOrUpdate(salesPerson);
            return salesPerson;
        }

        public IList<SalesPerson> FindAll() {
            IList<SalesPerson> salesPerson = ISalesPersonDao.FindAll();
            return salesPerson;
        }

        public SalesPerson FindById(int salesPersonId) {
            return ISalesPersonDao.FindById(salesPersonId);
        }

        public IList<SalesPerson> FindByTitleLike(string title) {
            return ISalesPersonDao.FindByTitleLike(title);
        }

        public SalesPerson FindByTitle(string title) {
            return ISalesPersonDao.FindByTitle(title);
        }

        [Transaction(ReadOnly = false)]
        public void Delete(int salesPersonId) {
            ISalesPersonDao.Delete(ISalesPersonDao.FindById(salesPersonId));
        }

        public IList<SalesPerson> SortSalesPerson(string param, bool asc)
        {
            return ISalesPersonDao.SortSalesPerson(param, asc);
        }

        #endregion

    }
}
